
char * Student::Input_Field (char * & field)
{
	gets(input_str);
	field = new char [strlen(input_str)+1];
	strcpy(field, input_str);
	return field;
}

Student::Student()
{
	key_id = 0;
	birth_day = 0;
	sex_person = unknown;
	
	first_name = NULL;
	name = NULL;
	last_name = NULL;
	txt_birth_day = NULL;
	txt_sex_person = NULL;
	phone_number = NULL;
	mail = NULL;
	
	student_line = NULL;
	//r_student_line = student_line;
}
	
void Student::Add_Line()
{
	//Goto_XY ();
	
	cout <<		"Enter First Name : ";
	Input_Field(first_name);

	cout <<		"Enter Name : ";
	Input_Field(name);

	cout <<		"Enter Last Name : ";
	Input_Field(last_name);

	cout <<		"Enter Birth day : ";
	Input_Field(txt_birth_day);

	cout <<		"Enter Sex : ";
	Input_Field(txt_sex_person);

	cout <<		"Enter Phone number : ";
	Input_Field(phone_number);

	cout <<		"Enter Mail : ";
	Input_Field(mail);
	
	
//	char * tmp_student_line = new char [strlen(first_name)+1];
//	strcpy(tmp_student_line, first_name);
}


char * Student::Get_Line (char * str_line, char sep)
{

	return str_line;
}
void Student::Show_Line(){}

void Student::Show()
{
cout << "\n\n" << "First Name [" << strlen(first_name) << "] : " << first_name;
cout << "\n" << "Name [" << strlen(name) << "] : " << name;
cout << "\n" << "Last Name [" << strlen(last_name) << "] : " << last_name;
cout << "\n" << "Birth Day [" << strlen(txt_birth_day) << "] : " << txt_birth_day;
cout << "\n" << "Sex [" << strlen(txt_sex_person) << "] : " << txt_sex_person;
cout << "\n" << "Phone Number [" << strlen(phone_number) << "] : " << phone_number;
cout << "\n" << "Mail [" << strlen(mail) << "] : " << mail;

}	

Student::~Student()
{
	
	delete first_name;
	delete name;
	delete last_name;
	delete txt_birth_day;
	delete txt_sex_person;
	delete phone_number;
	delete mail;

}


	
Group::Group()
{
	id_group = 0;
	gr_capacity = 0;
	size = 0;
	*gr_name = 0x00;
}
	
Group::Group (char * name, size_t capacity, size_t id)
{
	size = 0;
	if (strlen(name)> sizeof(gr_name)) name[sizeof(gr_name)] = 0x00; //Обрізання стрічки
	strcpy(gr_name, name);
	gr_capacity = 0;
	if (capacity> 0)
	{
		gr_capacity = capacity;
		person = new Student[gr_capacity];
	}
}
	
int Group::Add_Person ()
{
	if (size == gr_capacity)
		if (Extend (1) == 0) return 0;
	
	system("cls");
	cout << "\n" << "[LINE " << size+1 << "]" << "\n\n";
	person[size++].Add_Line();
	return size;
}


int Group::Extend (size_t size_add)
{
	if (size_add == 0) return gr_capacity;
	gr_capacity += size_add;
	tmp_person = new Student [gr_capacity];
	if (tmp_person == NULL) return 0;
		
	for(size_t i= 0; i< size; ++i)
	{
		tmp_person[i] = person[i];
	}
	delete [] person; 
//	Не розумію, чому програма зависає при розширенні дин.пам'яті, якщо delete [] person;

//При використанні this->person все працює, хоча не розумію чому.
	this->person = tmp_person;
	return gr_capacity;
}
void Group::Show()
{
	system("cls");
	cout << gr_name;
	cout << "\n" << "===============";
	for (size_t i= 0; i< size; ++i)
	{
		person[i].Show();
	}
}
	
	
Group::~Group()
{
	delete person;
}

